

<!DOCTYPE html>
<html lang="zh" data-default-color-scheme=&#34;auto&#34;>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/walker_sue/img/favicon.png">
  <link rel="icon" type="image/png" href="/walker_sue/img/favicon.png">
  <meta name="viewport"
        content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="description" content="">
  <meta name="author" content="lk">
  <meta name="keywords" content="">
  <title>常见规划问题（三） - Walker_Sue</title>

  <link  rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/css/bootstrap.min.css" />


  <link  rel="stylesheet" href="https://cdn.staticfile.org/github-markdown-css/4.0.0/github-markdown.min.css" />
  <link  rel="stylesheet" href="/walker_sue/lib/hint/hint.min.css" />

  
    
    
      
      <link  rel="stylesheet" href="https://cdn.staticfile.org/highlight.js/10.0.0/styles/github-gist.min.css" />
    
  

  


<!-- 主题依赖的图标库，不要自行修改 -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_ba1fz6golrf.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_kmeydafke9r.css">


<link  rel="stylesheet" href="/walker_sue/css/main.css" />

<!-- 自定义样式保持在最底部 -->


  <script  src="/walker_sue/js/utils.js" ></script>
  <script  src="/walker_sue/js/color-schema.js" ></script>
<meta name="generator" content="Hexo 5.3.0"></head>


<body>
  <header style="height: 70vh;">
    <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand"
       href="/walker_sue/">&nbsp;<strong>Walker</strong>&nbsp;</a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/">
                <i class="iconfont icon-home-fill"></i>
                主页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/walker_sue/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                <i class="iconfont icon-books"></i>
                文档
              </a>
              <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/">
                    
                    主题博客
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/docs/guide/">
                    
                    配置指南
                  </a>
                
                  
                  
                  
                  <a class="dropdown-item" target="_blank" rel="noopener" href="https://hexo.fluid-dev.com/docs/icon/">
                    
                    图标用法
                  </a>
                
              </div>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" data-toggle="modal" data-target="#modalSearch">&nbsp;<i
                class="iconfont icon-search"></i>&nbsp;</a>
          </li>
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" href="javascript:">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

    <div class="banner intro-2" id="background" parallax=true
         style="background: url('/walker_sue/img/default.png') no-repeat center center;
           background-size: cover;">
      <div class="full-bg-img">
        <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
          <div class="container page-header text-center fade-in-up">
    <span class="h2" id="subtitle">
    
</span>




<div class="mt-3">
  
  
    <span class="post-meta">
      <i class="iconfont icon-date-fill" aria-hidden="true"></i>
      <time datetime="2021-06-10 13:49" pubdate>
        June 10, 2021 pm
      </time>
    </span>
  
</div>

<div class="mt-1">
  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-chart"></i>
      1.4k 字
    </span>
  

  
    
    <span class="post-meta mr-2">
      <i class="iconfont icon-clock-fill"></i>
      
      
      14
       分钟
    </span>
  

  
  
</div>


</div>

          
        </div>
      </div>
    </div>
  </header>

  <main>
    
      

<div class="container-fluid">
  <div class="row">
    <div class="d-none d-lg-block col-lg-2"></div>
    <div class="col-lg-8 nopadding-md">
      <div class="container nopadding-md" id="board-ctn">
        <div class="py-5" id="board">
          <article class="post-content mx-auto" id="post">
            <!-- SEO header -->
            <h1 style="display: none">常见规划问题（三）</h1>
            
            <div class="markdown-body" id="post-body">
              <div align='center' ><font size='10'>机器学习-BI</font></div>


<hr>
<div align='center' ><font size='5'>Week_15</font></div>
<div align='center' ><font size='5'>优化算法汇总</font></div>

<hr>
<h1 id="优化算法总结"><a href="#优化算法总结" class="headerlink" title="优化算法总结"></a>优化算法总结</h1><h2 id="1-优化算法简介"><a href="#1-优化算法简介" class="headerlink" title="1.优化算法简介"></a>1.优化算法简介</h2><p>算法本质是一种按照固定步骤执行的过程。</p>
<p>优化算法也是这样一种过程，是一种根据概率按照固定步骤寻求问题的最优解的过程。与常见的排序算法、寻路算法不同的是，优化算法不具备等幂性，是一种<strong>概率算法</strong>。算法不断的<strong>迭代</strong>执行同一步骤直到结束，其流程如下图。</p>
<p><img src="NP01.png" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="等幂性"><a href="#等幂性" class="headerlink" title="等幂性"></a>等幂性</h3><p>等幂性即<strong>对于同样的输入，输出是相同的</strong>。</p>
<h3 id="概率算法"><a href="#概率算法" class="headerlink" title="概率算法"></a>概率算法</h3><p>概率算法的最大优点就是<strong>花费较少的代价来获取最高的收益</strong>，在现实中体现于节省时间，使用很少的时间得到一个不与最优解相差较多的结果。</p>
<h3 id="迭代过程"><a href="#迭代过程" class="headerlink" title="迭代过程"></a>迭代过程</h3><p>优化算法是一种概率算法，执行一次操作就得到最优结果几乎是不可能的，重复多次取得最优的概率也会增大。<br><img src="NP02.png" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="马尔可夫链"><a href="#马尔可夫链" class="headerlink" title="马尔可夫链"></a>马尔可夫链</h3><p><strong>马尔可夫链（Markov Chain, MC）</strong>,描述的是<strong>状态转移的过程中,当前状态转移的概率只取决于上一步的状态,与其他步的状态无关</strong>。简单来说就是当前的结果只受上一步的结果的影响。</p>
<p><img src="markov.git" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="使用场景"><a href="#使用场景" class="headerlink" title="使用场景"></a>使用场景</h3><p><img src="NP03.png" srcset="/walker_sue/img/loading.gif"></p>
<h2 id="2-优化算法分类"><a href="#2-优化算法分类" class="headerlink" title="2.优化算法分类"></a>2.优化算法分类</h2><h3 id="2-1常见的优化算法"><a href="#2-1常见的优化算法" class="headerlink" title="2.1常见的优化算法"></a>2.1常见的优化算法</h3><p>在分类之前，我们先列举一下常见的优化算法（不然我们拿什么分类呢？）。</p>
<p>　　1遗传算法Genetic algorithm</p>
<p>　　2粒子群优化算法Particle Swarm Optimization</p>
<p>　　3差分进化算法Differential Evolution</p>
<p>　　4人工蜂群算法Artificial Bee Colony</p>
<p>　　5蚁群算法Ant Colony Optimization</p>
<p>　　6人工鱼群算法Artificial Fish Swarm Algorithm</p>
<p>　　7杜鹃搜索算法Cuckoo Search</p>
<p>　　8萤火虫算法Firefly Algorithm</p>
<p>　　9灰狼算法Grey Wolf Optimizer</p>
<p>　　10鲸鱼算法Whale Optimization Algorithm</p>
<p>　　11群搜索算法Group search optimizer</p>
<p>　　12混合蛙跳算法Shuffled Frog Leaping Algorithm</p>
<p>　　13烟花算法fireworks algorithm</p>
<p>　　14菌群优化算法Bacterial Foraging Optimization</p>
<h3 id="2-2常见的优化算法分类"><a href="#2-2常见的优化算法分类" class="headerlink" title="2.2常见的优化算法分类"></a>2.2常见的优化算法分类</h3><p><img src="NP04.png" srcset="/walker_sue/img/loading.gif"></p>
<h2 id="3-几种典型的优化算法"><a href="#3-几种典型的优化算法" class="headerlink" title="3.几种典型的优化算法"></a>3.几种典型的优化算法</h2><h3 id="3-1-遗传算法"><a href="#3-1-遗传算法" class="headerlink" title="3.1 遗传算法"></a>3.1 遗传算法</h3><p>遗传算法启发于生物的繁殖与dna的重组，遗传算法包含三个操作（算子）：交叉，变异和选择操作。<br></p>
<p>遗传算法(Genetic Algorithms，GA)是一种模拟自然中生物的遗传、进化以适应环境的智能算法。由于其算法流程简单，参数较少优化速度较快，效果较好，在图像处理、函数优化、信号处理、模式识别等领域有着广泛的应用 <br></p>
<p>　　在遗传算法（GA）中，每一个待求问题的候选解被抽象成为种群中一个个体的基因。种群中个体基因的好坏由表示个体基因的候选解在待求问题中的所的得值来评判。种群中的个体通过与其他个体交叉产生下一代，每一代中个体均只进行一次交叉。两个进行交叉的个体有一定几率交换一个或者多个对应位的基因来产生新的后代。每个后代都有一定的概率发生变异。发生变异的个体的某一位或某几位基因会变异成其他值。最终将以个体的适应度值为概率选取个体保留至下一代。<br></p>
<p><img src="genic01.png" srcset="/walker_sue/img/loading.gif"></p>
<p><strong>遗传算法：</strong><br></p>
<ul>
<li>通过模拟自然进化过程（达尔文生物进化论）搜索最优解的方法，遗传操作包括：选择、交叉和变异</li>
<li>算法核心：参数编码、初始群体的设定、适应度函数、遗传操作设计、控制参数设定</li>
<li>以一种群体中的所有个体为对象，利用随机化技术指导对一个被编码的参数空间进行高效搜索</li>
</ul>
<p><strong>遗传算法特点：</strong><br></p>
<ul>
<li>直接对结构对象进行操作，不存在求导和函数连续性的限定</li>
<li>具有内在的隐并行性和更好的全局寻优能力</li>
<li>采用概率化的寻优方法，不需要确定的规则就能自动获取和指导优化的搜索空间，自适应地调整搜索方向</li>
</ul>
<p><img src="genic02.png" srcset="/walker_sue/img/loading.gif"><br><img src="genic03.png" srcset="/walker_sue/img/loading.gif"><br><img src="genic04.png" srcset="/walker_sue/img/loading.gif"><br><img src="genic05.png" srcset="/walker_sue/img/loading.gif"><br><img src="genic06.png" srcset="/walker_sue/img/loading.gif"><br><img src="genic07.png" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="3-2-PSO粒子群算法"><a href="#3-2-PSO粒子群算法" class="headerlink" title="3.2 PSO粒子群算法"></a>3.2 PSO粒子群算法</h3><p>粒子群算法（Particle Swarm Optimization,PSO）是一种模仿鸟群、鱼群觅食行为发展起来的一种进化算法。其概念简单易于编程实现且运行效率高、参数相对较少，应用非常广泛。粒子群算法于1995年提出，距今（2019）已有24年历史。<br></p>
<p>　　粒子群算法中每一个粒子的位置代表了待求问题的一个候选解。每一个粒子的位置在空间内的好坏由该粒子的位置在待求问题中的适应度值决定。每一个粒子在下一代的位置有其在这一代的位置与其自身的速度矢量决定，其速度决定了粒子每次飞行的方向和距离。在飞行过程中，粒子会记录下自己所到过的最优位置 Ｐ，群体也会更新群体所到过的最优位置Ｇ 。粒子的飞行速度则由其当前位置、粒子自身所到过的最优位置、群体所到过的最优位置以及粒子此时的速度共同决定<br></p>
<p><img src="pso01.png" srcset="/walker_sue/img/loading.gif"><br><img src="pso02.png" srcset="/walker_sue/img/loading.gif"><br><img src="pso03.png" srcset="/walker_sue/img/loading.gif"></p>
<h3 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h3><ul>
<li>1.<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/a1949c3bfbaf">优化算法笔记</a></li>
<li>2.<a target="_blank" rel="noopener" href="https://www.jianshu.com/p/ef9602955ca6">马尔科夫链(Markov Chain)</a></li>
<li>3.<a target="_blank" rel="noopener" href="https://mp.weixin.qq.com/s?__biz=MzU1NTUxNTM0Mg==&mid=2247489378&idx=1&sn=4507090d90f09561e5a675a6d4106893&chksm=fbd27bc3cca5f2d581114a5f2f587d58fc57620399d9b909b8c07a1d152f685b782aab03fbf5&mpshare=1&scene=1&srcid=11273P7xL2PHQAcb1mgI9BDj#rd">13张动图助你彻底看懂马尔科夫链、PCA和条件概率!</a></li>
</ul>

            </div>
            <hr>
            <div>
              <div class="post-metas mb-3">
                
                  <div class="post-meta mr-3">
                    <i class="iconfont icon-category"></i>
                    
                      <a class="hover-with-bg" href="/walker_sue/categories/%E8%BF%90%E7%AD%B9%E5%AD%A6/">运筹学</a>
                    
                      <a class="hover-with-bg" href="/walker_sue/categories/%E8%BF%90%E7%AD%B9%E5%AD%A6/%E8%A7%84%E5%88%92%E9%97%AE%E9%A2%98/">规划问题</a>
                    
                  </div>
                
                
                  <div class="post-meta">
                    <i class="iconfont icon-tags"></i>
                    
                      <a class="hover-with-bg" href="/walker_sue/tags/BI/">BI</a>
                    
                      <a class="hover-with-bg" href="/walker_sue/tags/%E8%BF%90%E7%AD%B9%E5%AD%A6/">运筹学</a>
                    
                      <a class="hover-with-bg" href="/walker_sue/tags/%E7%BA%BF%E6%80%A7%E8%A7%84%E5%88%92%E9%97%AE%E9%A2%98/">线性规划问题</a>
                    
                  </div>
                
              </div>
              
                <p class="note note-warning">本博客所有文章除特别声明外，均采用 <a target="_blank" href="https://creativecommons.org/licenses/by-sa/4.0/deed.zh" rel="nofollow noopener noopener">CC BY-SA 4.0 协议</a> ，转载请注明出处！</p>
              
              
                <div class="post-prevnext row">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/walker_sue/2021/06/25/week16-VRP/">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">常见规划问题（四）</span>
                        <span class="visible-mobile">Vorheriger</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/walker_sue/2021/06/04/week14-NP2/">
                        <span class="hidden-mobile">常见规划问题（二）</span>
                        <span class="visible-mobile">Nächster</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>
    
      <div class="d-none d-lg-block col-lg-2 toc-container" id="toc-ctn">
        <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;TOC</p>
  <div id="tocbot"></div>
</div>

      </div>
    
  </div>
</div>

<!-- Custom -->


    
  </main>

  
    <a id="scroll-top-button" href="#" role="button">
      <i class="iconfont icon-arrowup" aria-hidden="true"></i>
    </a>
  

  
    <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">Suchen</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v"
                 for="local-search-input">Stichwort</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>
  

  

  <footer class="text-center mt-5 py-3">
  <div class="footer-content">
     <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
  </div>
  

  

  
</footer>

<!-- SCRIPTS -->
<script  src="https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js" ></script>
<script  src="https://cdn.staticfile.org/twitter-bootstrap/4.4.1/js/bootstrap.min.js" ></script>
<script  src="/walker_sue/js/debouncer.js" ></script>
<script  src="/walker_sue/js/main.js" ></script>

<!-- Plugins -->


  
    <script  src="/walker_sue/js/lazyload.js" ></script>
  



  



  <script defer src="https://cdn.staticfile.org/clipboard.js/2.0.6/clipboard.min.js" ></script>
  <script  src="/walker_sue/js/clipboard-use.js" ></script>







  <script  src="https://cdn.staticfile.org/tocbot/4.11.1/tocbot.min.js" ></script>
  <script>
    $(document).ready(function () {
      var boardCtn = $('#board-ctn');
      var boardTop = boardCtn.offset().top;

      tocbot.init({
        tocSelector: '#tocbot',
        contentSelector: '#post-body',
        headingSelector: 'h1,h2,h3,h4,h5,h6',
        linkClass: 'tocbot-link',
        activeLinkClass: 'tocbot-active-link',
        listClass: 'tocbot-list',
        isCollapsedClass: 'tocbot-is-collapsed',
        collapsibleClass: 'tocbot-is-collapsible',
        collapseDepth: 0,
        scrollSmooth: true,
        headingsOffset: -boardTop
      });
      if ($('.toc-list-item').length > 0) {
        $('#toc').css('visibility', 'visible');
      }
    });
  </script>



  <script  src="https://cdn.staticfile.org/typed.js/2.0.11/typed.min.js" ></script>
  <script>
    function typing(id, title){
        var typed = new Typed('#' + id, {
            strings: [
              '  ',
              title + "&nbsp;",
            ],
            cursorChar: "_",
            typeSpeed: 70,
            loop: false,
        });
        typed.stop();
        $(document).ready(function () {
            $(".typed-cursor").addClass("h2");
            typed.start();
        });
    }
    
        typing("subtitle", "常见规划问题（三）")
    
  </script>


  <script  src="https://cdn.staticfile.org/anchor-js/4.2.2/anchor.min.js" ></script>
  <script>
    anchors.options = {
      placement: "right",
      visible: "hover",
      
    };
    var el = "h1,h2,h3,h4,h5,h6".split(",");
    var res = [];
    for (item of el) {
      res.push(".markdown-body > " + item)
    }
    anchors.add(res.join(", "))
  </script>



  <script  src="/walker_sue/js/local-search.js" ></script>
  <script>
    var path = "/walker_sue/local-search.xml";
    var inputArea = document.querySelector("#local-search-input");
    inputArea.onclick = function () {
      searchFunc(path, 'local-search-input', 'local-search-result');
      this.onclick = null
    }
  </script>



  <script  src="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.js" ></script>
  <link  rel="stylesheet" href="https://cdn.staticfile.org/fancybox/3.5.7/jquery.fancybox.min.css" />

  <script>
    $('#post img:not(.no-zoom img, img[no-zoom]), img[zoom]').each(
      function () {
        var element = document.createElement('a');
        $(element).attr('data-fancybox', 'images');
        $(element).attr('href', $(this).attr('src'));
        $(this).wrap(element);
      }
    );
  </script>





  

  
    <!-- MathJax -->
    <script>
      MathJax = {
        tex: {
          inlineMath: [['$', '$'], ['\\(', '\\)']]
        },
        options: {
          renderActions: {
            findScript: [10, doc => {
              document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
                const display = !!node.type.match(/; *mode=display/);
                const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
                const text = document.createTextNode('');
                node.parentNode.replaceChild(text, node);
                math.start = { node: text, delim: '', n: 0 };
                math.end = { node: text, delim: '', n: 0 };
                doc.math.push(math);
              });
            }, '', false],
            insertedScript: [200, () => {
              document.querySelectorAll('mjx-container').forEach(node => {
                let target = node.parentNode;
                if (target.nodeName.toLowerCase() === 'li') {
                  target.parentNode.classList.add('has-jax');
                }
              });
            }, '', false]
          }
        }
      };
    </script>

    <script async src="https://cdn.staticfile.org/mathjax/3.0.5/es5/tex-svg.js" ></script>

  











</body>
</html>
